from main.model.pcb_management.pcb_manager_fifo import PCBManagerFIFO
from main.model.devices.cpu_controller import RRCPUController

class Scheduler(object):
    
    def __init__(self, device_manager, round_robin_enable=False, pcb_manager=None):
        self.__device_manager     = device_manager
        self.__pcb_manager        = pcb_manager or PCBManagerFIFO()
        self.__round_robin_enable = round_robin_enable
        
    def setup(self):
        if(self.__round_robin_enable):
            self.cpu.controller = RRCPUController(self.cpu)
    
    def add(self, pcb):
        self.pcb_manager.add(pcb)
        
    def has_next(self):
        return self.pcb_manager.has_next()
    
    def next(self):
        return self.pcb_manager.next()
        
    @property
    def pcb_manager(self): return self.__pcb_manager
    
    @property
    def cpu(self): return self.__device_manager.cpu
        
    